package exp3;

import java.util.*;

public class Mach2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        Stack<Character> stack = new Stack<>();
        Boolean flag = true;
        for (int i = 0; i < str.length(); i++) {
            char temp = str.charAt(i);
            if (temp == '(' || temp == '[' || temp == '{') {
				stack.push(temp);
            } else if (temp == '/' && str.charAt(i + 1) == '*') {
                stack.push('l');
                i++;
            } else if (!stack.isEmpty() && temp == ')') {
                if (stack.peek() == '(') {
                    stack.pop();
                } else {
                    flag = false;
                    break;
                }
            } else if (temp == ']') {
                if (!stack.isEmpty() && stack.peek() == '[') {
                    stack.pop();
                } else {
                    flag = false;
                    break;
                }
            } else if (temp == '}') {
                if (!stack.isEmpty() && stack.peek() == '{') {
                    stack.pop();
                } else {
                    flag = false;
                    break;
                }
            } else if (!stack.isEmpty() && temp == '*' && str.charAt(i + 1) == '/') {
                if (stack.peek() == 'l') {
                    stack.pop();
                    i++;
                } else {
                    flag = false;
                    break;
                }
            }
        }
        System.out.println(flag);
    }
}
